import { Injectable } from '@angular/core';

@Injectable()
export class StockService {
  constructor() { }

  private stocks: Stock[] = [
    new Stock('000676', '华大基因', 20.00, 3, '华大基因旗下产品', ['生物科技']),
    new Stock('601100', '恒立液压', 22.00, 2.5, '恒立液压', ['工业']),
    new Stock('102151', '北斗星通', 25.00, 3.5, '北斗星通', ['科技']),
    new Stock('601939', '建设银行', 30.00, 4, '银行类产品', ['金融'])
  ];

  getStocks(): Stock[] {
    return this.stocks;
  }
  getStock(id: string): Stock {
    let singleStock = this.stocks.find(stock => stock.id === id);
    if (!singleStock) {
      singleStock = new Stock('', '', 0, 0, '', []);
    }
    return singleStock;
  }
}

export class Stock {
  constructor(
    // 股票代码
    public id: string,
    // 股票名称
    public name: string,
    // 股票单价
    public price: number,
    // 股票评级
    public rating: number,
    // 股票描述
    public desc: string,
    // 股票类别
    public stockSort: Array<string>
  ) {

  }

}
